package com.balance.anole.erp.security.login.service.impl;

import com.balance.anole.admin.to.LoginUserTO;
import com.balance.anole.erp.security.login.model.RetailLoginUser;
import com.balance.anole.erp.security.login.service.ILoginHandler;
import com.balance.anole.erp.security.login.service.LoginService;
import com.balance.anole.erp.util.ServicesCenter;

public class LocalLoginHandler implements ILoginHandler {

	@Override
	public RetailLoginUser login(LoginUserTO user) {
		RetailLoginUser rlu = null;
		//check with local database for account validation.
		LoginService ls = ServicesCenter.getServicesCenter().getService(LoginService.class);
		LoginUserTO userTO = ls.login(user);
		//set local login menus:
		if(userTO != null){
			rlu = new RetailLoginUser();
			rlu.setLoginUserTO(userTO);
			rlu.setNavigates(new LocalMenuConfiguration("/command-conf.xml").getMenus());
		}

		return rlu;
	}

}
